﻿using RBAC.Repository.RabbitInterfae;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Traceability.Domain;
using Traceability.Service.Interfae;

namespace Traceability.Service.Impl
{
    public class BreedService : IBreedService
    {
        private readonly IBreedRepository _repository;
        public BreedService(IBreedRepository repository)
        {
            _repository = repository;
        }
        /// <summary>
        /// 添加养殖信息
        /// </summary>
        /// <param name="breed"></param>
        /// <returns></returns>
        public async Task<int> AddBreed(Breeds breed)
        {
           return await _repository.AddAsync(breed);
        }
        /// <summary>
        /// 显示养殖信息
        /// </summary>
        /// <param name="bath"></param>
        /// <returns></returns>
        public async Task<List<Breeds>> GetBreeds(string bath)
        {
           var listobj=from a in await _repository.GetAllAsync()
                       where!a.BreedsDel&& a.Batch == bath
                       select a;
            return listobj.ToList();
        }
       /// <summary>
       /// 修改养殖信息
       /// </summary>
       /// <param name="breed"></param>
       /// <returns></returns>
        public async Task<int> UpdateBreed(Breeds breed)
        {
           return await _repository.UpdateAsync(breed);
        }
    }
}
